﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="EdAsignacionTarea.ascx.cs" Inherits="SistemaWeb.Editores.EdAsignacionTarea" %>
<%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>

<style type="text/css">
        .list-item {
            font:normal 11px tahoma, arial, helvetica, sans-serif;
            padding:3px 10px 3px 10px;
            border:1px solid #fff;
            border-bottom:1px solid #eeeeee;
            white-space:normal;
            color:#555;
        }
        
        .list-item h3 {
            display:block;
            font:inherit;
            font-weight:bold;
            color:#222;
        }
</style>

<ext:Store runat="server" ID="RecursosStore">          
    <Reader>
        <ext:JsonReader ReaderID="id">
            <Fields>
                <ext:RecordField Name="id" />
                <ext:RecordField Name="nombre" />
                <ext:RecordField Name="perfil" />
                <ext:RecordField Name="seniority" />
            </Fields>
        </ext:JsonReader>
    </Reader>
</ext:Store>

<ext:Store runat="server" ID="RecursosGrillaStore">          
    <Reader>
        <ext:JsonReader ReaderID="id">
            <Fields>
                <ext:RecordField Name="id" />
                <ext:RecordField Name="nombre" />
                <ext:RecordField Name="perfil" />
                <ext:RecordField Name="seniority" />
                <ext:RecordField Name="sueldo" />
                <ext:RecordField Name="horas" />
                <ext:RecordField Name="usuario" />
            </Fields>
        </ext:JsonReader>
    </Reader>
</ext:Store>


<ext:Window ID="popupAsignacion" runat="server" Collapsible="true" 
            Icon="GroupAdd" Title="Asignacion de Recursos" 
            Width="800" Height="500" AutoShow="true" Modal="true" ShowOnLoad="false" BodyStyle="padding:10px">
    <Body>
        <ext:FitLayout ID="FitLayout1" runat="server">
            <ext:TabPanel ID="TabPanel1" runat="server" ActiveTabIndex="0" Height="300">
                <Tabs>
                    <ext:Tab ID="TabAsignacion" runat="server" Title="Asignacion" Icon="Add" BodyStyle="padding:10px;" AutoDataBind="true">
                        <Body>
                                <ext:ColumnLayout ID="ColumnLayout1" runat="server" Split="true" FitHeight="true">
                                    <Columns>
                                        <ext:LayoutColumn ColumnWidth="0.50">
                                            <ext:Panel ID="Panel1" runat="server" Title="Tarea" BodyStyle="padding:15px;">
                                                <Body>
                                                    <ext:FormLayout ID="FormLayout1" runat="server">                              
                                                         <Anchors>
                                                            <ext:Anchor>
                                                                <ext:TextField ID="idTB" ReadOnly="true" runat="server" FieldLabel="ID" Width="200">
                                                                </ext:TextField>
                                                            </ext:Anchor>
                                                            <ext:Anchor>
                                                                <ext:TextField ID="nombreTB" ReadOnly="true" runat="server" FieldLabel="Tarea" Width="200">
                                                                </ext:TextField>
                                                            </ext:Anchor>
                                                            <ext:Anchor>
                                                                <ext:TextField ID="PerfilTB" ReadOnly="true" runat="server" FieldLabel="Perfil" Width="200">
                                                                </ext:TextField>
                                                            </ext:Anchor>
                                                            <ext:Anchor>
                                                                <ext:TextField ID="SeniorityTB" ReadOnly="true" runat="server" FieldLabel="Seniority" Width="200">
                                                                </ext:TextField>
                                                            </ext:Anchor>
                                                            <ext:Anchor>
                                                                <ext:TextArea 
                                                                    ID="descripcionTA" 
                                                                    runat="server" 
                                                                    FieldLabel="Descripcion" 
                                                                    Height="150" 
                                                                    Width="200"
                                                                    ReadOnly="true"
                                                                    />
                                                            </ext:Anchor>
                                                        </Anchors>                                        
                                                    </ext:FormLayout>
                                                </Body>                                               
                                            </ext:Panel>
                                        </ext:LayoutColumn>
                                        
                                        <ext:LayoutColumn ColumnWidth="0.50">
                                            <ext:Panel ID="Panel2" runat="server" Title="Asignacion" BodyStyle="padding:15px;">
                                                <Body>
                                                    <ext:FormLayout ID="FormLayout2" runat="server">                                
                                                        <Anchors>
                                                            <ext:Anchor> 
                                                                <ext:ComboBox
                                                                    ID="RecursosDL" 
                                                                    runat="server"
                                                                    StoreID="RecursosStore" 
                                                                    Width="200"
                                                                    Editable="false"
                                                                    DisplayField="nombre"
                                                                    ValueField="id"
                                                                    TypeAhead="true" 
                                                                    Mode="Local"
                                                                    FieldLabel="Recurso"
                                                                    ForceSelection="true"
                                                                    TriggerAction="All"
                                                                    EmptyText="Seleccione un Recurso..."
                                                                    ItemSelector="div.list-item"
                                                                    SelectOnFocus="true">
                                                                    <Template ID="Template1" runat="server">
                                                                        <tpl for=".">
                                                                            <div class="list-item">
                                                                                 <h3>{nombre}</h3>
                                                                                 {perfil} | {seniority}
                                                                            </div>
                                                                        </tpl>
                                                                    </Template>    
                                                                </ext:ComboBox>
                                                            </ext:Anchor>
                                                            <ext:Anchor>
                                                                <ext:DateField ID="fechaTB" runat="server" FieldLabel="Fecha Creacion" Width="200" AllowBlank="false">
                                                                </ext:DateField>
                                                            </ext:Anchor>
                                                            <ext:Anchor>
                                                                <ext:TextField ID="horasTB" runat="server" FieldLabel="Cantidad Horas" AllowBlank="false" InvalidText="El campo debe ser numerico" MaxLength="100" MinLength="1" Width="200" CausesValidation="true">
                                                                </ext:TextField>
                                                            </ext:Anchor>
                                                            <ext:Anchor>
                                                                <ext:Checkbox ID="verificarCompatibilidadCK" runat="server" Checked="true" FieldLabel="Verficar Compatibilidad">                                                                    
                                                                </ext:Checkbox>
                                                            </ext:Anchor>
                                                      </Anchors>
                                                    </ext:FormLayout>
                                                </Body>
                                                <Buttons>
                                                    <ext:Button ID="AsignarCM" runat="server" Text="Asignar" Icon="UserAdd">
                                                        <AjaxEvents>
                                                            <Click OnEvent="AsignarRecurso" Failure="Ext.MessageBox.alert('Error', 'Ocurrio un error inesperado, no se realizo la asignación.');">
                                                                <EventMask ShowMask="true" Target="CustomTarget" CustomTarget="={#{popupAsignacion}.body}" />
                                                            </Click>
                                                        </AjaxEvents>
                                                    </ext:Button>
                                                </Buttons>
                                            </ext:Panel>
                                        </ext:LayoutColumn>
                                    </Columns>
                                </ext:ColumnLayout>                              
                        </Body>
                    </ext:Tab>
                    <ext:Tab ID="TabRecursos" runat="server" Title="Recursos Asignados" Icon="Group" BodyStyle="padding:5px;  AutoDataBind="true">
                        <Body>
                              <ext:FitLayout ID="fit1" runat="server">
                                    <ext:GridPanel ID="GrillaRecursos" runat="server" StoreID="RecursosGrillaStore" StripeRows="true" Icon="Group" 
                                        Title="Recursos Asignados a la Tarea" TrackMouseOver="true" Width="700" Height="250">
                                        <ColumnModel ID="ColumnModel1" runat="server">
                                            <Columns>
                                                <ext:Column ColumnID="ID" Header="id" Sortable="true" DataIndex="id" Width="50" />
                                                <ext:Column Header="Nombre" Sortable="true" DataIndex="nombre" Width="200" />
                                                <ext:Column Header="Perfil" Sortable="true" DataIndex="perfil" Width="100" />
                                                <ext:Column Header="Seniority" Sortable="true" DataIndex="seniority" Width="100" /> 
                                                <ext:Column Header="Sueldo" Sortable="true" DataIndex="sueldo" Width="100" /> 
                                                <ext:Column Header="Horas" Sortable="true" DataIndex="horas" Width="100" />                                                       
                                            </Columns>
                                        </ColumnModel>
                                        <SelectionModel>
                                            <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" SingleSelect="true">
                                            </ext:RowSelectionModel>
                                        </SelectionModel>
                                        <LoadMask ShowMask="true" />
                                        <BottomBar>
                                            <ext:PagingToolbar ID="PagingToolBar1" runat="server" PageSize="12" StoreID="Store1" />
                                        </BottomBar>
                                    </ext:GridPanel>
                            </ext:FitLayout>             
                        </Body>
                    </ext:Tab>
                </Tabs>
            </ext:TabPanel>
        </ext:FitLayout>
    </Body>
    <Buttons>        
        <ext:Button ID="CancelarCM" runat="server" Text="Volver" Icon="ArrowUndo">
            <Listeners>
                <Click Handler="#{popupAsignacion}.hide();" />
            </Listeners>
        </ext:Button>
    </Buttons>
</ext:Window>
